﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Capstone_project.DatabaseAccessLayer;

namespace Capstone_project
{
    public partial class frmMain : Form
    {
        int dem = 0;
        public frmMain()
        {
            InitializeComponent();
        }

        #region MOVE or LEAVE MOUSE
        private void mouseMove(Label abc)
        {
            abc.BackColor = Color.LightSteelBlue;
        }
        private void mouseLeave(Label abc)
        {
            abc.BackColor = Color.Transparent;
        }

        private void lblStaffTracking_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblStaffTracking);
        }

        private void lblStaffTracking_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblStaffTracking);
        }

        private void lblTracking_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblTracking);
        }

        private void lblTracking_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblTracking);
        }

        private void lblProjecttracking_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblProjecttracking);
        }

        private void lblProjecttracking_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblProjecttracking);
        }

        private void lblChangePassword_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblChangePassword);
        }

        private void lblChangePassword_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblChangePassword);
        }

        private void lblChangePermission_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblChangePermission);
        }

        private void lblChangePermission_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblChangePermission);
        }

        private void lblCreateAccount_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblCreateAccount);
        }

        private void lblCreateAccount_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblCreateAccount);
        }

        private void lblSearchStaff_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblSearchStaff);
        }

        private void lblSearchStaff_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblSearchStaff);
        }

        private void lblStaffList_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblStaffList);
        }

        private void lblStaffList_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblStaffList);
        }

        private void lblStaffManagement_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblStaffManagement);
        }

        private void lblStaffManagement_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblStaffManagement);
        }

        private void lblSearchTasks_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblSearchTasks);
        }

        private void lblSearchTasks_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblSearchTasks);
        }

        private void lblReport_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblReport);
        }

        private void lblReport_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblReport);
        }

        private void lblAssignTask_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblAssignTask);
        }

        private void lblAssignTask_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblAssignTask);
        }

        private void lblEditTasks_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblEditTasks);
        }

        private void lblEditTasks_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblEditTasks);
        }

        private void lblTaskManagement_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblTaskManagement);
        }

        private void lblTaskManagement_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblTaskManagement);
        }

        private void lblAddModule_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblAddModule);
        }

        private void lblAddModule_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblAddModule);
        }

        private void lblAddCustomer_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblAddCustomer);
        }

        private void lblAddCustomer_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblAddCustomer);
        }

        private void lblSearchProject_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblSearchProject);
        }

        private void lblSearchProject_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblSearchProject);
        }

        private void lblProjectInformation_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblProjectInformation);
        }

        private void lblProjectInformation_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblProjectInformation);
        }

        private void lblInitilizeProject_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblInitilizeProject);
        }

        private void lblInitilizeProject_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblInitilizeProject);
        }

        private void lblProjectManagement_MouseMove(object sender, MouseEventArgs e)
        {
            mouseMove(lblProjectManagement);
        }

        private void lblProjectManagement_MouseLeave(object sender, EventArgs e)
        {
            mouseLeave(lblProjectManagement);
        }
        #endregion

        private void lblHome_Click(object sender, EventArgs e)
        {
            panelContent.Controls.Clear();
        }

        #region Main Menu click
        private void LayoutVisible(FlowLayoutPanel abc)
        {
            abc.Visible = true;
            abc.BackColor = Color.LightSkyBlue;
        }
        private void labelAfterClick(Label abc)
        {
            abc.BackColor = Color.LightSteelBlue;
        }
        private void labelNotClick(Label abc)
        {
            abc.BackColor = Color.Transparent;
        }
        private void lblProjectManagement_Click_1(object sender, EventArgs e)
        {
            dem++;
            if (dem % 2 == 1)
            {
                LayoutVisible(flowLayoutPanelProject);
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelAfterClick(lblProjectManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
            else
            {
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelNotClick(lblProjectManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
        }

        private void lblTaskManagement_Click_1(object sender, EventArgs e)
        {
            dem++;
            if (dem % 2 == 1)
            {
                LayoutVisible(flowLayoutPanelTask);
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelAfterClick(lblTaskManagement);
                labelNotClick(lblProjectManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
            else
            {
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelNotClick(lblProjectManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
        }

        private void lblStaffManagement_Click_1(object sender, EventArgs e)
        {
            dem++;
            if (dem % 2 == 1)
            {
                LayoutVisible(flowLayoutPanelStaff);
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelAfterClick(lblStaffManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblProjectManagement);
                labelNotClick(lblTracking);
            }
            else
            {
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelNotClick(lblProjectManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
        }

        private void lblTracking_Click_1(object sender, EventArgs e)
        {
            dem++;
            if (dem % 2 == 1)
            {
                LayoutVisible(flowLayoutPanelTracking);
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelStaff.Visible = false;
                labelAfterClick(lblTracking);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblProjectManagement);
                labelNotClick(lblStaffManagement);
            }
            else
            {
                flowLayoutPanelProject.Visible = false;
                flowLayoutPanelStaff.Visible = false;
                flowLayoutPanelTask.Visible = false;
                flowLayoutPanelTracking.Visible = false;
                labelNotClick(lblProjectManagement);
                labelNotClick(lblTaskManagement);
                labelNotClick(lblStaffManagement);
                labelNotClick(lblTracking);
            }
        }
        #endregion

        #region Sub Menu Click
        private void lblInitilizeProject_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblInitilizeProject);
            panelContent.Controls.Clear();
            frmAddNewProject newproject = new frmAddNewProject();
            newproject.TopLevel = false;
            newproject.Dock = DockStyle.Fill;
            newproject.Visible = true;
            panelContent.Controls.Add(newproject);
        }

        private void lblProjectInformation_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblProjectInformation);
            panelContent.Controls.Clear();
            frmProject projectinformation = new frmProject();
            projectinformation.TopLevel = false;
            projectinformation.Dock = DockStyle.Fill;
            projectinformation.Visible = true;
            panelContent.Controls.Add(projectinformation);
        }

        private void lblSearchProject_Click_1(object sender, EventArgs e)
        {
            labelAfterClick(lblSearchProject);
            panelContent.Controls.Clear();
            frmSearchProject searchproject = new frmSearchProject();
            searchproject.TopLevel = false;
            searchproject.Dock = DockStyle.Fill;
            searchproject.Visible = true;
            panelContent.Controls.Add(searchproject);
        }

        private void lblAddCustomer_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblAddCustomer);
            panelContent.Controls.Clear();
            frmAddNewCustomer addnewcustomer = new frmAddNewCustomer();
            addnewcustomer.TopLevel = false;
            addnewcustomer.Dock = DockStyle.Fill;
            addnewcustomer.Visible = true;
            panelContent.Controls.Add(addnewcustomer);
        }

        private void lblAddModule_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblAddModule);
            panelContent.Controls.Clear();
            frmCreateNewTaskgroup addnewmodule = new frmCreateNewTaskgroup();
            addnewmodule.TopLevel = false;
            addnewmodule.Dock = DockStyle.Fill;
            addnewmodule.Visible = true;
            panelContent.Controls.Add(addnewmodule);
        }

        private void lblEditTasks_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblEditTasks);
            panelContent.Controls.Clear();
            frmAddNewTask edittasks = new frmAddNewTask();
            edittasks.TopLevel = false;
            edittasks.Dock = DockStyle.Fill;
            edittasks.Visible = true;
            panelContent.Controls.Add(edittasks);
        }

        private void lblAssignTask_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblAssignTask);
            panelContent.Controls.Clear();
            frmAssignTask assigntask = new frmAssignTask();
            assigntask.TopLevel = false;
            assigntask.Dock = DockStyle.Fill;
            assigntask.Visible = true;
            panelContent.Controls.Add(assigntask);
        }

        private void lblReport_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblReport);
            panelContent.Controls.Clear();
            Form1 report = new Form1();
            report.TopLevel = false;
            report.Dock = DockStyle.Fill;
            report.Visible = true;
            panelContent.Controls.Add(report);
        }

        private void lblSearchTasks_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblSearchTasks);
            panelContent.Controls.Clear();
            frmSearchTask searchtask = new frmSearchTask();
            searchtask.TopLevel = false;
            searchtask.Dock = DockStyle.Fill;
            searchtask.Visible = true;
            panelContent.Controls.Add(searchtask);
        }

        private void lblStaffList_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblStaffList);
            panelContent.Controls.Clear();
            frmAddNewStaff stafflist = new frmAddNewStaff();
            stafflist.TopLevel = false;
            stafflist.Dock = DockStyle.Fill;
            stafflist.Visible = true;
            panelContent.Controls.Add(stafflist);
        }

        private void lblSearchStaff_Click_1(object sender, EventArgs e)
        {
            labelAfterClick(lblSearchStaff);
            panelContent.Controls.Clear();
            frmSearchStaff searchstaff = new frmSearchStaff();
            searchstaff.TopLevel = false;
            searchstaff.Dock = DockStyle.Fill;
            searchstaff.Visible = true;
            panelContent.Controls.Add(searchstaff);
        }

        private void lblCreateAccount_Click(object sender, EventArgs e)
        {
            labelAfterClick(lblCreateAccount);
            panelContent.Controls.Clear();
            frmAddnewAccount addnewaccount = new frmAddnewAccount();
            addnewaccount.TopLevel = false;
            addnewaccount.Dock = DockStyle.Fill;
            addnewaccount.Visible = true;
            panelContent.Controls.Add(addnewaccount);
        }
        #endregion

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void lnkLogout_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Common.username.Clear();
            Common.password.Clear();
            frmLogin login = new frmLogin();
            this.Hide();
            login.Show();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            lblUsername.Text = Common.username[0].ToString();
            lblPermission.Text = Common.permission;
            if (Common.permission == "Admin" || Common.permission == "PM/PL")
            {
                lblInitilizeProject.Visible = true;
                lblEditTasks.Visible = true;
                lblAddCustomer.Visible = true;
                lblAddModule.Visible = true;
            }
            else if (Common.permission == "Staff")
            {
                lblInitilizeProject.Visible = false;
                lblEditTasks.Visible = false;
                lblAssignTask.Visible = false;
                lblAddCustomer.Visible = false;
                lblAddModule.Visible = false;
                lblStaffList.Visible = false;
                lblCreateAccount.Visible = false;
                lblChangePermission.Visible = false;
            }
        }

        private void lblUsername_Click(object sender, EventArgs e)
        {
            frmPersonalInformation personalinfor = new frmPersonalInformation();
            personalinfor.ShowDialog();
        }
    }

}

